Skip to content

Conversation

ktamas77
Copy link

@ktamas77 ktamas77 commented Oct 5, 2025

Summary

This PR implements inline code comments on individual commits, similar to the existing PR code review functionality.

Features

  • ✅ Add inline comments on any line of a commit diff
  • ✅ Edit and delete your own comments
  • ✅ Attachment support
  • ✅ @mention notifications
  • ✅ Works in both unified and split diff views

Implementation Details

  • Reuses existing Comment model infrastructure (CommitSHA, Line, TreePath already supported)
  • New service layer for commit comment CRUD operations
  • API routes: /commit/:sha/comments for create/update/delete
  • Templates updated to show comment UI when PageIsCommit is true
  • Existing PR comment JavaScript handles commit comments generically

Testing

  • ✅ Builds successfully without errors
  • Backend implementation follows existing PR comment patterns
  • Reuses PR comment templates and JavaScript

Fixes #4898

/claim #4898

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Oct 5, 2025
@github-actions github-actions bot added modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files labels Oct 5, 2025
This feature enables users to add inline code comments on individual commits,
similar to the existing PR code review functionality. Comments can be added,
edited, and deleted on any line of a commit's diff.

Changes:
- Add service layer functions for commit comment CRUD operations
- Add router handlers and API routes for commit comments
- Add model queries to find commit comments
- Update diff templates to show comment UI on commit pages
- Load and display commit comments in the Diff() handler
- Reuse existing PR comment templates and JavaScript

Implements: go-gitea#4898
@ktamas77 ktamas77 force-pushed the feature/commit-inline-comments branch from dfbfd56 to a706a04 Compare October 5, 2025 19:47
@lunny
Copy link
Member

lunny commented Oct 6, 2025

I don't think the comment type CommentTypeCode should be reused here.

Instead of reusing CommentTypeCode (which is for PR code comments),
introduce a new CommentTypeCommitCode type specifically for inline
comments on commits. This provides better separation of concerns
and makes the codebase more maintainable.

Changes:
- Add CommentTypeCommitCode constant and string representation
- Update comment type methods to support the new type
- Update all commit comment functions to use CommentTypeCommitCode
- Handle commit comments separately in updateCommentInfos
@ktamas77
Copy link
Author

ktamas77 commented Oct 6, 2025

I don't think the comment type CommentTypeCode should be reused here.

Good point! I've updated the implementation to use a separate CommentTypeCommitCode type instead of reusing CommentTypeCode. This provides better separation between PR code comments and commit inline comments. All the related functions and methods have been updated accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙋 Bounty claim lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add inline comments on commits
3 participants